<template>
	<view class="container">
		<view v-for="(item, index) in list" :key="index" @click="itemClick(item)" class="item">
			<view>
				{{item.typeName}}
			</view>
			<u-icon name="arrow-right" color="#A6A6A6" :size="18"></u-icon>
		</view>
		
		<u-empty class="noContent" v-if="emptyShow" text="暂时没有设置检查项目哦～"  mode="list"></u-empty>
	</view>
</template>

<script>
	import { getXjTargetProject, getTargetStatus } from '@/api/xj.js'
	export default {
		data() {
			return {
				list: [],
				emptyShow: false,
			}
		},
		onLoad(options) {
			console.log(options);
			this.targetClassId = options.targetClassId
			this.getProject()
		},
		methods: {
			getProject() {
				getXjTargetProject(this.targetClassId).then(res => {
					console.log(res);
					this.list = res.data;
					if (this.list.length === 0) {
						this.emptyShow = true;
					}
				})
			},
			
			itemClick(item) {
				this.getTargetStatus(item)
			},
			
			getTargetStatus(item) {
				getTargetStatus({targetId: item.id, targetClassId: this.targetClassId}).then(res => {
					console.log(res)
					if (res.data.status === 1) {
						this.$u.toast(res.data.msg)
					} else {
						this.$u.route({
							type: 'redirectTo',
							url: '/pages_operate/xj/xj-check-page',
							params: {
								targetClassId: this.targetClassId,
								targetId: item.id,
							}
						})
					}
				})
			}
		}
	}
</script>

<style lang="scss">
	page{
		background-color: $app-page-bg-color;
	}
	
	.container{
		padding-left: $app-page-padding;
		padding-right: $app-page-padding;;
	}
	
	.item{
		background: #FFFFFF;
		border-radius: 20rpx;
		display: flex;
		flex-direction: row;
		justify-content: space-between;
		padding-left: 35rpx;
		padding-top: 20rpx;
		padding-bottom: 20rpx;
		padding-right: 35rpx;
		margin-top: 30rpx;
		margin-bottom: 30rpx;

		.title {
			font-size: 24rpx;
			font-family: PingFang SC;
			font-weight: 400;
			color: #333333;
			line-height: 65rpx;
		}
	}
</style>
